﻿///<reference path="vswd-ext_2.0.2.js" />
Ext.BLANK_IMAGE_URL = 'Images/s.gif';

Ext.onReady(function(){
    Ext.QuickTips.init();
    
    Ext.Ajax.request({
        url: 'Trans/Base/Lang.aspx',
        params: {
            action: 'lang',
            marks: "'home','index','logout','navigator'"
        },
        success: function(response, opts) {
            var langObj = Ext.decode(response.responseText);
            langObj = langObj['rows'][0];
            
            var treeLoader = new Ext.tree.TreeLoader({
                dataUrl: 'Menu.aspx?action=menu'    
            });
                
            var rootNode = new Ext.tree.AsyncTreeNode({
                text: langObj['index'],
                leaf: false,
                expanded: true
            });
            
            var vp = new Ext.Viewport({
                layout: 'border',
                items: [{
                    region: 'north',
                    cls: 'docs-header',
                    xtype: 'box',
                    border: false,
                    height: 36,
                    el: 'header',
                    margins: '0 0 5 0'
                },{
                    region: 'west',
                    xtype: 'treepanel',
                    split: true,
                    useArrows: true,
                    collapsible: true,
                    collapseMode: 'mini',
                    title: langObj['navigator'],
                    bodyStyle: 'padding: 5px',
                    miniSize: 200,
                    width: 200,
                    loader: treeLoader,
                    root: rootNode,
                    listeners: {
                        click: function(node, e) {
                            if (node.isLeaf()) {
                                e.stopEvent();
                                var tp = Ext.getCmp('_tabpanel');
                                var t =tp.getComponent(node.id);
                                if (!t) {
                                    var t = tp.add({
                                        id: node.id,
                                        title: node.text,
                                        closable: true,
                                        html:"<iframe src='"+node.attributes.href+"?page_id="+node.id+"&w="+tp.getActiveTab().getInnerWidth()+"&h="+tp.getActiveTab().getInnerHeight()+"' width='100%' height='100%' border='0' scrolling='auto' frameborder='0'></iframe>"
                                    });
                                }
                                
                                tp.setActiveTab(t);
                            }
                        }
                    }
                },{
                    region: 'center',
                    xtype: 'tabpanel',
                    id: '_tabpanel',
                    minTabWidth:150,
			        tabWidth:200,
                    activeTab: 0,
                    items: {
                        title: langObj['home'],
                        html: ''
                    }
                }]
            });
           
        },
        failure: function() {
        
        }
    });
    
    Ext.get('loading').remove();
    Ext.fly('loading-mask').fadeOut({
        remove:true
    });
});